package com.centaline.androidsalesblog.adapter;

import android.content.Context;
import android.view.View;

import com.centaline.androidsalesblog.R;
import com.centaline.androidsalesblog.adapter.viewholder.EsfDealHistoryVH;
import com.centaline.androidsalesblog.model.businissobject.EsfDealHistoryBo;
import com.centaline.androidsalesblog.utils.DateUtil;
import com.centaline.androidsalesblog.utils.PriceUtil;
import com.centanet.framework.base.BaseAdapter1;

import java.util.ArrayList;
import java.util.Locale;

/**
 * 小区成交历史
 * Created by guilin on 16/1/29.
 */
public class EsfDealHistoryAdapter extends BaseAdapter1<EsfDealHistoryVH> {

    private final ArrayList<EsfDealHistoryBo> list;

    public EsfDealHistoryAdapter(Context context, ArrayList<EsfDealHistoryBo> list) {
        super(context);
        this.list = list;
    }

    @Override
    protected int inflateByLayoutId() {
        return R.layout.item_esf_deal_history;
    }

    @Override
    protected EsfDealHistoryVH viewHolder(View view) {
        return new EsfDealHistoryVH(view);
    }

    @Override
    public void onBindViewHolder(EsfDealHistoryVH holder, int position) {
        final EsfDealHistoryBo esfDealHistoryBo = list.get(position);
        holder.atv_content.setText(String.format(Locale.CHINA, "%s  %s平  %s",
                esfDealHistoryBo.getHouseType(), esfDealHistoryBo.getSize(), esfDealHistoryBo.getFloorDisplay()));
        holder.atv_deal_date.setText(DateUtil.format(esfDealHistoryBo.getDealTime(),
                DateUtil.FORMAT1, DateUtil.FORMAT2));
        holder.atv_avg_price.setText(String.format(Locale.CHINA, "%s元/平", esfDealHistoryBo.getUnitPrice()));
        holder.atv_total_price.setText(String.format(Locale.CHINA, "总价:%s", PriceUtil.dealPrice(esfDealHistoryBo.getDealPrice())));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
